package com.company.salarysystem;

// 普通员工类（按小时计薪）
public class RegularEmployee extends Employee {
    private double hourlyWage;  // 时薪
    private double workHours;   // 工作时长（小时）

    public RegularEmployee(String name, String empId, double hourlyWage, double workHours) {
        super(name, empId);
        this.hourlyWage = hourlyWage;
        this.workHours = workHours;
    }

    // 计算薪资：时薪 × 工作时长
    @Override
    public double calculateSalary() {
        if (workHours < 0) {
            throw new IllegalArgumentException("工作时长不能为负数，当前：" + workHours + "小时");
        }
        if (workHours > 200) {
            throw new IllegalArgumentException("工作时长超过上限（200小时），当前：" + workHours + "小时");
        }
        return hourlyWage * workHours;
    }

    // 实现薪资明细：时薪 × 时长 = 总薪资
    @Override
    public String getSalaryDetails() {
        return hourlyWage + "元/小时 × " + workHours + "小时 = " + (hourlyWage * workHours) + "元";
    }
}